﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Models;
using PetaPoco;

namespace DAL.MySQL
{
    public class admintypeDAL
    {
        private Database db = DbScoure.DataBase();
        public admintypeEntity GetOne(int id)
        {
           return db.SingleOrDefault<admintypeEntity>("select * from admintype where id=@0", id);
        }

        public List<admintypeEntity> GetList(string where,string order,params object[] args)
        {
            var list = db.Fetch<admintypeEntity>("select * from admintype where 1=1 " + where+" order by "+order, args);
            return list;
        }

        public Page<admintypeEntity> GetPageList(int pagenum,int pagesize,string where,string order, params object[] args)
        {
            var pagelist=db.Page<admintypeEntity>(pagenum,pagesize, "select * from admintype where 1=1 " + where + " order by " + order, args);
            return pagelist;
        }

        public int Update(object obj, int ID)
        {
            return db.Update("admintype", "ID", obj, ID);
        }
        public admintypeEntity Save(admintypeEntity model)
        {
            db.Save("admintype", "ID", model);
            return model;
        }

        public bool Del(int id)
        {
            try
            {
                db.Delete("admintype", "ID", null, id);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
        public bool Del(admintypeEntity model)
        {
            try
            {
                db.Delete("admintype", "ID", model);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
    }
}
